package pe.gob.sedapal.scmultimedia.config;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.StringUtils;

public class ApplicationContext{
	public static org.springframework.context.ApplicationContext ctx;
	
	public ApplicationContext() {
		super();
		//ctx = new AnnotationConfigApplicationContext(SpringJavaConfigStyle.class);	
		ctx = new ClassPathXmlApplicationContext("classpath:config/applicationContext.xml");

		/*prueba*/
		/*UsuarioService user= (UsuarioService)ctx.getBean("usuarioService");
		List<Usuario> lista= user.listarUsuariosActivos();
		System.out.println("user"+lista.size());*/
	}	
	
	public static void init(){
		if(ctx==null){
			new ApplicationContext();
		}
	}
	
	@SuppressWarnings("rawtypes")
	public static Object getBean(Class clase){
		init();
		return ctx.getBean(StringUtils.uncapitalize(clase.getSimpleName()));
	}	
	
}
